<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
	<jsp:include page="/WEB-INF/jsp_lib/validate.jsp" />
	<jsp:include page="/WEB-INF/jsp_lib/layer.jsp" />
	<script type="text/javascript">
	 	$(function(){
		 	$("#emp").hide();
	 	})
		function query() {
			$("#form1").submit();
		}
		function pushForm(mac_id) {
			$("input[name='mac_id']").val(mac_id);
			var url = "${path}/ix/mac/push/push_form.htm";
			$("#form1").attr("action", url);
			
			$("#form1").submit();
		}
		function selectAll(){
	        var all = document.getElementById("choose");
	        var allIds = document.getElementsByName("check_id");
	        for (var i=0;i<allIds.length;i++)
	        {
	            allIds[i].checked = all.checked;
	        }
	    }
	    function resultFormYes(){
	   		$("input:checkbox").each(function(){
	   		 	 $(this).attr("disabled",true); 
	   		});
	   		
	        var check_ids = "";
	        var $check_ids = $("input[name='check_id']:checked");
	        $.each($check_ids,function(i,n){
	            check_ids += $(this).val()+ ",";
	        });
	        if(check_ids.length>0){
	            $("input[name='check_ids']").val(check_ids);
	            $("#emp").show();
	        }else{
	            ohSnap("请选择需下发的仪器！","warning");
	        }
	    }
	    function myNo(){
	    	$("input:checkbox").each(function(){
	   		 	 $(this).attr("disabled",false); 
	   		});
			$("#emp").hide();
		}
		function myEdit(){
			var bank = $("input[name='bank_id']").val();
		
			if(bank.length==0){
				alert("请选择机构！");
			}else{
				var url = "${path}/ix/mac/push/push_result.htm";
				$("#form1").attr("action", url);
				$("#form1").submit();
			}
		}
	
	</script>
</head>
<body>
<div>
	<jsp:include page="/WEB-INF/jsp_lib/tip.jsp" />
	<jsp:include page="/WEB-INF/jsp/common/selectUserLowerBank.jsp" />
	<form action="${path}/ix/mac/push/list.htm" id="form1" method="post">
		<input type="hidden" name="mac_id" />
		<input type="hidden" name="check_ids" />
		<h2>
			<div>设备分发</div>
		</h2>
		<div class="query">
			<table width="100%" border="0" align="center" cellpadding="0" cellspacing="5">
				<tr>
					<td width="60" align="right">
						<strong>编号：</strong>
					</td>
					<td width="200" align="left">
						<input name="srh_name" value="${srh_name}" type="text" />
					</td>
					<td align="left">
						<a href="javascript:query();"> 
							<img src="${path}/style_cp/img/query.jpg" name="Image4" width="85"
								height="27" border="0" id="Image4" />
						</a>
					</td>
				</tr>
			</table>
		</div>
		<table width="100%" class="listlindex">
			<tr>
				<th><input type="checkbox" id="choose" onclick="selectAll()"/></th>
				<th>设备编号</th>
				<th>设备mac地址</th>
				<th>录入人员</th>
				<th>录入机构</th>
				<th>录入时间</th>
				<th>设备状态</th>
				<th>操作</th>
			</tr>
			<c:if test="${fn:length(macList)==0}">
				<tr>
					<td colspan="8"><div class="tip_div">暂无记录.</div></td>
				</tr>
			</c:if>
			<c:forEach items="${macList}" var="v">
				<tr>
					<td><input type="checkbox" name="check_id" value="${v._id}"/></td> 
					<td>${v.code}</td>
					<td>${v.mac}</td>
					<td>${v.ucode}</td>
					<td>${v.bname}[${v.bcode}]</td>
					<td>
						<fmt:formatDate value="${v.created}" pattern="yyyy-MM-dd HH:mm" />
					</td>
					<td>${v.flag}${v.flag_stop}</td>
					<td><a href="javascript:pushForm('${v._id}');">【分发】</a></td>
				</tr>
			</c:forEach>
		</table>
		<div id="response"></div>
		<div class="options">
			<div class="quotes">
				<a href="javascript:resultFormYes();" class="asave" style="float:left">
					【下发】
				</a>
				<page:page page="${page}" />
			</div>
			<div class="clear"></div>
		</div>
		<div id="emp" style="height: 400px;position:fixed;left:36%;top:30%;" hidden="true">
			<div class="query">
				<h2>
					<div>操作</div>
				</h2>
				<table width="100%" class="listlindex">
					<tr>
						<input name="bank_id" type="hidden" value="" type="text" />
						<th align="right" >下发机构：</th>
						<td align="left" colspan="3" >
							<input name="bank_name" readonly="readonly" onClick="getArea();" style="width:300px" 
								value="" type="text" maxlength="100" /> 
							<a href="javascript:getArea()">
								<img alt="请选择使用机构" src="${path }/style_cp/img/02.gif" />
							</a>
						</td>
					</tr>
					<tr>
						<th align="right">备注：</th>
						<td align="left" colspan="3">
							<textarea maxlength="150" name="note" rows="5" cols="50"></textarea>
						</td>
					</tr>
				</table>	
				<div>&nbsp;</div>
				<a href="javascript:myEdit();">【确定】</a>
				<a href="javascript:myNo();">【取消】</a>
			</div>
		</div>	
	</form>

</div>
</body>
</html>